主题
获取推理配置 - YoloGetModelConfig
函数简介
读取当前句柄已保存的推理调参。
接口名称
YoloGetModelConfigDLL 调用
long YoloGetModelConfig(long ola, long modelHandle);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug 对象指针,由 CreateCOLAPlugInterFace 生成。 |
| modelHandle | 长整数型 | 模型句柄 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
auto cfg = ola.YoloGetModelConfig(modelHandle);csharp
using OLAPlug;
var ola = new OLAPlugServer();
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0)
{
// 模型加载失败,请检查路径与密码
}
var cfg = ola.YoloGetModelConfig(modelHandle);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
# 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if modelHandle == 0:
# 模型加载失败,请检查路径与密码
pass
cfg = ola.YoloGetModelConfig(modelHandle)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var cfg = ola.YoloGetModelConfig(modelHandle);cpp
var ola = com("OlaPlug.OlaSoft")
// 加载加密 YOLO 模型包
var modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var cfg = ola.YoloGetModelConfig(modelHandle)vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
' 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
If modelHandle = 0 Then
' 模型加载失败,请检查路径与密码
End If
cfg = ola.YoloGetModelConfig(modelHandle)text
.局部变量 ola, OLAPlug
ola.创建 ()
' 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel(“models/yolov8n.olam“, “your_password“, 0)
.如果真 (modelHandle = 0)
' 模型加载失败,请检查路径与密码
.如果真结束
cfg = ola.YoloGetModelConfig(modelHandle)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
// 加载加密 YOLO 模型包
var modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var cfg = ola.YoloGetModelConfig(modelHandle);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
// 加载加密 YOLO 模型包
长整数 modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
自动 cfg = ola.YoloGetModelConfig(modelHandle)cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
auto cfg = ola.YoloGetModelConfig(modelHandle);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
// 加载加密 YOLO 模型包
long modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
long cfgJsonPtr = YoloGetModelConfig(instance, modelHandle);
if (cfgJsonPtr != 0) {
char cfgJson[512] = {0};
GetStringFromPtr(cfgJsonPtr, cfgJson, sizeof(cfgJson));
FreeStringPtr(cfgJsonPtr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
// 加载加密 YOLO 模型包
long modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0)
{
// 模型加载失败,请检查路径与密码
}
long cfgJsonPtr = YoloGetModelConfig(instance, modelHandle);
if (cfgJsonPtr != 0) {
StringBuilder cfgJson = new StringBuilder(GetStringSize(cfgJsonPtr) + 1);
GetStringFromPtr(cfgJsonPtr, cfgJson, cfgJson.Capacity);
FreeStringPtr(cfgJsonPtr);
string cfgJsonStr = cfgJson.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
# 加载加密 YOLO 模型包
modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0)
if modelHandle == 0:
# 模型加载失败,请检查路径与密码
pass
cfgJsonPtr = YoloGetModelConfig(instance, modelHandle)
if cfgJsonPtr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(cfgJsonPtr, buf, 512)
ola.FreeStringPtr(cfgJsonPtr)
cfgJson = buf.value.decode("utf-8")返回值
长整数型:JSON 字符串指针。
注意事项
- 需要插件已开通 YOLO 模块权限(Reg、Login的FeatureList中包含YOLO特性)。
- 模型元数据见 ModelInfo与ModelConfig说明。
- 模型元数据请用 YoloGetModelInfo。
- 返回的 JSON 字符串须调用 FreeStringPtr 释放。
